﻿using UnityEngine;
using System.Collections;

public class Choice0 : MonoBehaviour {
	// Use this for initialization
	void Start () {
        if (transform.parent.GetComponent<EventMsg>().m_EventChoice == EVENT_CHOICE.CHOICE_STATE)
        {
            GetComponent<UISprite>().spriteName = "NewspaperBtn1";
            transform.localPosition = new Vector3(0, -1.4f);
            GetComponent<UISprite>().width = 220;
            GetComponent<BoxCollider>().size = new Vector3(220, 100);
            GetComponent<UIButton>().normalSprite = GetComponent<UISprite>().spriteName;
        }
	}
	
	// Update is called once per frame
	void Update () {
	
	}

    void OnClick()
    {
        switch (transform.parent.GetComponent<EventMsg>().m_strTimedEventID)
        {
            case "Retreat":
                break;

            case "Attack":
                break;

            case "SupplyBeCutOff":
                GameObject.Find("MysoldierBtn").GetComponent<RightButtons>().OnClick();
                GameObject.Find("RightWdw").GetComponent<RightWdwMgr>().m_bSelectUnitPage = true;

                switch(Random.Range(0,3))
                {
                    case 0:
                        GameObject.Find("EventMgr").GetComponent<EventMgr>().EventMsgSend(5.0f, "SupplyBeCutOff_Restore");
                        break;
                    case 1:
                        GameObject.Find("EventMgr").GetComponent<EventMgr>().EventMsgSend(5.0f, "SupplyBeCutOff_Dead");
                        break;
                    case 2:
                        GameObject.Find("EventMgr").GetComponent<EventMgr>().EventMsgSend(5.0f, "SupplyBeCutOff_Barely");
                        break;
                }
                break;

            case "Volunteer":
                GameObject.Find("FriendSpawn").GetComponent<FriendSpawn>().m_HireApplyList.Add(GameObject.Find("DataLogic").GetComponent<DataManager>().MakeOneRandUnit(ASSN_TYPE.DEFAULT, CLASS_TYPE.POLICE));
                GameObject.Find("FriendSpawn").GetComponent<FriendSpawn>().FriendSpawnExcute();

                if (Random.Range(0, 1) == 0) // 0,2로 바꿔야함
                {
                    GameObject.Find("EventMgr").GetComponent<EventMgr>().EventMsgSend(15.0f, "Volunteer_TurnEnemy");
                    GameObject.Find("SceneDataMgr").GetComponent<SceneDataMgr>().GoneToMissionUnitList.Add(Calculate.FindThisUnit(GameObject.Find("SceneDataMgr").GetComponent<SceneDataMgr>().UnitList[GameObject.Find("SceneDataMgr").GetComponent<SceneDataMgr>().UnitList.Count - 1]));

                }

                break;
        }

        GameTime.TimeSpeed_Play();
        Destroy(transform.parent.gameObject);
    }
}
